<?php
class Design_Controller extends Template_Controller {

	public $template = 'client/index';
	public $language = '';
    public function __construct()
    {
        parent::__construct();
        
        //Css
        //$this->template->css = $this->site['theme_url'].'article/article.css';
       	$this->language = $this->get_client_lang();
    }
    
	public function __call($method, $arguments)
	{
		// Disable auto-rendering
		$this->auto_render = FALSE;
	}
	
    public function index()
    {	
		$this->page();
		
    }
    public function page()
    {
    	$language= $this->get_client_lang();
		$this->template->content = new View('design/index');
		$model = new Designs_Model(); 
		//$this->db->limit(10,0);	
		$mDesigns = $model->get_with_active($this->language);
		$this->template->content->mDesigns= $mDesigns;
		
		//
		$model = new Cate_design_Model(); 
		$mCate = $model->get_with_active($this->language);
		$this->template->content->mCate= $mCate;
    }
    public function detail($id)
    {
    	$this->template->content = new View('design/detail');
    	$language = $this->get_client_lang();
		$model = new Designs_Model(); 
		$this->db->where('designs.designs_id',$id);
		$mlist = $model->get_with_active($language);
    	$this->template->content->mr = $mlist[0];
		
		$model = new Cate_design_Model(); 
		$this->db->where('cate_design.cate_design_id',$mlist[0]['cate_design_id']);
		$mCate = $model->get_with_active($this->language);
		$this->template->content->mCate= $mCate[0];
		
		$mlistOther = $this->other_designs($id,$mlist[0]['cate_design_id']);
		//print_r($mlistOther);
		$this->template->content->mlistOther = $mlistOther;
    }
	
	public function other_designs($id,$cate_id='')

    {

    	$language = $this->get_client_lang();

		$model = new Designs_Model(); 

		$this->db->where('designs.designs_id <>',$id);
		$this->db->where('designs.cate_design_id',$cate_id);
		$mlist = $model->get_with_active($language);

    	return $mlist;

    }
}
?>